package com.mmsj;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

/**
 * @author ChuXuan
 */
public class OptionMenuActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_option_menu);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.my_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }

    @Override
    public boolean onOptionsItemSelected(@NonNull MenuItem item) {
        int id = item.getItemId();
       if(id == R.id.menu_item_1)
           Toast.makeText(this, "menu_item_1", Toast.LENGTH_SHORT).show();
       else if(id == R.id.menu_item_2)
           Toast.makeText(this, "menu_item_2", Toast.LENGTH_SHORT).show();
       else if(id == R.id.menu_item_3)
           Toast.makeText(this, "menu_item_3", Toast.LENGTH_SHORT).show();
       else if (id == R.id.menu_item_4)
           Toast.makeText(this, "menu_item_4", Toast.LENGTH_SHORT).show();
       else if (id == R.id.menu_item_5)
           Toast.makeText(this, "menu_item_5", Toast.LENGTH_SHORT).show();
       return super.onOptionsItemSelected(item);
    }
}